package 回溯.剑指;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

/**
 * todo
 *
 * @author songZiHao
 * @version 1.0.0
 * @ClassName 剑指II079.java
 * @createTime 2022年10月31日 20:38:00
 */
public class 剑指II079 {
	List<List<Integer>> result = new ArrayList<>();

	public List<List<Integer>> subsets(int[] nums) {
		backTrace(nums,0);
		return result;
	}

	LinkedList<Integer> list = new LinkedList<>();

	public void backTrace(int[] nums, int curIndex) {
		result.add(new ArrayList<>(list));

		for (int i = curIndex; i < nums.length; i++) {
			list.add(nums[i]);
			backTrace(nums, i + 1);
			list.removeLast();
		}
	}
}
